'''
Author: your name
Date: 2020-10-29 13:52:27
LastEditTime: 2020-10-29 14:19:02
LastEditors: Please set LastEditors
Description: In User Settings Edit
FilePath: \python-study\博客学习\深入\特殊方法与多范式.py
'''
class SampleMore(object):
    def __call__(self, a):
        return a + 5


if __name__=="__main__":
    # 非常特殊的实例方法，即 __call__()。该方法的功能类似于在类中重载 () 运算符，使得类实例对象可以像调用普通函数那样，以“对象名()”的形式使用。
    add = SampleMore()     # A function object
    print(add(2))          # Call function    
    map(add, [2, 4, 5])    # Pass around function object
    # print('abc'+'def')
    # print('abc'.__add__('def'))
    # print((1.8).__mul__(2.0))
    # print(True.__or__(False))
    # li = [1, 2, 3, 4, 5, 6]
    # print(li[3])
    # print(li.__getitem__(3))
    # li.__setitem__(3, 0)
    # print(li[3])